package com.cw.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cw.data.ConstantEnum;
import com.cw.data.Result;
import com.cw.pojo.TbContent;
import com.cw.service.ContentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("frontContentController")
public class FrontContentController {

    @Reference
    private ContentService contentService;

    @RequestMapping("getContentInfo")
    @ResponseBody
    public Result getContentInfo(Long categoryId) {

        try {

            List<TbContent> contentList = contentService.getContentList(categoryId);

            return Result.result(ConstantEnum.SUCCESS).setData(contentList);

        }catch (Exception e) {

            e.printStackTrace();

            return Result.result(ConstantEnum.ERROR);
        }
    }
}
